﻿using System;
using fastCSharp;

namespace diantou.web.contest
{
    /// <summary>
    /// 注册用户
    /// </summary>
    [fastCSharp.code.cSharp.webView(IsPool = true, IsReferer = false)]
    partial class joinUser : view<joinUser>
    {
        /// <summary>
        /// 用户集合
        /// </summary>
        [fastCSharp.emit.webView.clearMember]
        private web.user.userRelation[] users;
        /// <summary>
        /// 注册用户
        /// </summary>
        /// <param name="contestId">比赛标识</param>
        /// <param name="page">分页号</param>
        /// <returns>是否成功</returns>
        private bool loadView(int contestId, string randomCode, int page)
        {
            if (base.loadView(contestId, randomCode))
            {
                diantou.dataAccess.user[] values;
                if (diantou.dataAccess.clientCache.ContestRegister.IsData)
                {
                    subArray<int> userIds = contestRegister.Default.GetUserIds(contestId).toSubArray();
                    pageInfo.Count = userIds.Count;
                    values = diantou.dataAccess.clientCache.User.Get(userIds.GetPageDesc(pageInfo.Size = fastCSharp.config.pub.Default.PageSize, pageInfo.Page = page));
                }
                else values = diantou.dataAccess.clientCache.User.Get(diantou.dataAccess.tcpCall.focusContest.getUserIds(contestId, dataModel.focus.type.Register, pageInfo.Size = fastCSharp.config.pub.Default.PageSize, pageInfo.Page = page, out pageInfo.Count));
                users = values.getArray(value => new web.user.userRelation { User = value, UserId = currentUserId });
                if (requestHeader.IsSearchEngine) pageInfo.Path = contest.Path.JoinUser.ToPageString();
                return true;
            }
            return false;
        }
    }
}